package com.rules.admin.controller;


import com.rules.admin.entity.RecentlyLog;
import com.rules.admin.entity.RecentlyPackage;
import com.rules.admin.service.RecentlyLogService;
import com.rules.admin.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@RequestMapping({"/recentlyLogs"})
@Controller
public class RecentlyLogController {
   @Autowired
   private RecentlyLogService recentlyLogService;

   @RequestMapping(
      method = {RequestMethod.POST}
   )
   @ResponseBody
   public Map<String, Object> saveOrUpateLog(@RequestBody RecentlyLog recentlyLog) {
      this.recentlyLogService.saveOrUpdate(recentlyLog);
      return ResultUtils.getSuccessResultData();
   }

   @ResponseBody
   @RequestMapping(
      value = {"/packages"},
      method = {RequestMethod.GET}
   )
   public List<RecentlyPackage> getRecentPackages() {
      return this.recentlyLogService.getRecentlyPackage();
   }
}
